import React, { useContext, useMemo } from 'react';
import { Button, Space } from 'antd';
import { WorkflowHndTaskBtn } from '@/components/WorkflowCommonCopy';
import { AllBtnsConfig } from '../mconfig';
import { ApplyControllerContext } from '../common';
import { RollbackOutlined } from '@ant-design/icons';
import { getPosIDs, getTenantID, getUserID } from '@/utils';
import { QC_SQSTATE, SHZ_SQSTATE, SQ_flowBusinessType } from '../common/Format';
import { SHTH_CHECKSTATE } from '../../Acommon';
import moment from 'moment';
import { ILoadMapTypeAll } from '@/common';
export const DetailInfoBottomBtnView: React.FC = () => {
  /** 引入上下文 */
  const { taskId, curRes, pageType, applyDetailInfo, applyForm, oldApplyInfo, styleFixCls, reloadDetail, setInvalidState, setOAMessageRun } = useContext(
    ApplyControllerContext,
  );

  /** 按钮是否显示 */
  const allBtnsMemo = useMemo(() => {
    return AllBtnsConfig(curRes, applyDetailInfo, false, applyForm, oldApplyInfo, pageType);
  }, [curRes, applyDetailInfo, applyForm, oldApplyInfo, pageType]);

  return (
    <div className={`${styleFixCls}infoViewOA-bottomBtnBox-spaceItemBox`}>
      <Space>
        {/* 流程节点弹框 */}
        <WorkflowHndTaskBtn
          flowDetailInfo={applyDetailInfo}
          flowBusinessType={SQ_flowBusinessType()}
          reloadCallback={reloadDetail}
          requestController={'purchaseApplyController'}
          clickSuccessFun={() => {
            setOAMessageRun({
              id: taskId,
              isRemark: 2,
              viewType: 1,
              endTime: moment()?.format('YYYY-MM-DD HH:mm:ss'),
            });
          }}
          applyHeader={'apply'}
          revokeRequestUrl={'/purchaseApplyController/invalid'}
          revokeRequestState={`${getTenantID()}${ILoadMapTypeAll?.PURAPPLY_STATE}`}
          isShowRevokeStateList={[SHZ_SQSTATE()]}
          revokeTitle={applyDetailInfo?.applyTitle}
          revokeSuccessCallback={reloadDetail}
        />

        {/* {curRes['/purchaseApplyController/invalid'] &&
          applyDetailInfo?.id &&
          applyDetailInfo?.applyerID == getUserID() &&
          applyDetailInfo?.applyPositionID == getPosIDs() &&
          applyDetailInfo?.state == SHZ_SQSTATE() && (
            <Button
              type="primary"
              danger
              // icon={<RollbackOutlined />}
              onClick={() => {
                setInvalidState({ isShow: true, resObj: applyDetailInfo });
              }}
            >
              撤销
            </Button>
          )} */}
      </Space>
    </div>
  );
};
